Sub - Workflow

Workflow is series of activities that follows execution path.

An Activity is a collection of instructions that can include script, logging, approvals, record processing, timers, wait time, rollback activity etc.

To create a workflow we need to go for workflow editor and we can drag and drop required activity in workflow.

We can also drag and drop any other workflow in current workflow.

We can create scratchpad variable to pass values from one activity to another.

If we are using If activity then we can specify condition as follows-

If_activity
  1. Following is the main workflow and we have added one sub workflow in main workflow.
  2. Main Workflow

 

 

  1. Sub Workflow-
  2. Sub Workflow

To send data from main workflow to sub workflow we need to create one input variable in sub workflow to hold value coming from main workflow as follows-

CreateInputvariable.PNG

We can specify input filed name, type, length etc as follows-

Specifyinputvariabledetails

Create scratchpad variable in main workflow

CreateScratchpadVariable

Set value coming from main workflow to input variable Trainer Course

setValuetoInputVariable

To access value coming in input variable assign it to some other filed like short description

 

SetShortDesc

To test this run the catalog item. Add Trainer name as Meghana. then automatically data present is scratchpad variable will be passed to sub workflow. After providing approval, check the workflow. short description should hold data coming from main workflow i.e. Service Now.

 

TestWF

To send data back from sub workflow to main workflow we need to create scratchpad variable in sub workflow as follows -

ScratchpadForCost

Then need to create return activity as follows and specify scratchpad variable as ${workflow.scratchpad.cost}

ReturnValueActivity

Now go to main workflow and set map return value to as follows-  

MapRetunValueTo

Then assign the value coming from sub workflow to description filed as follows,

AssignCostComingFromSubworkflow

 

Main Workflow-

Main Workflow

Sub Workflow -

Sub Workflow

Result-

Result